package com.chinasofti.mydate.myjdk8datetime;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class JKD8DateDemo5 {
    public static void main(String[] args) throws ParseException {
        //method1();
        String s = "2023年04月13日 13:00:00";
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(s, pattern);
        System.out.println("parse = " + parse);
    }

    private static void method1() {
        LocalDateTime localDateTime = LocalDateTime.of(2023,04,13,13,0);
        System.out.println("localDateTime = " + localDateTime);
        //将localDateTime格式化为字符串
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        String s = localDateTime.format(pattern);
        System.out.println("s = " + s);
    }


}